/*
+--------------------------------------------------------
+	Copyright (c) 2004-2007 WeSofts
+	JavaScript Project for wespace
+	http://www.wesofts.com
+--------------------------------------------------------
*/

/*
+--------------------------------------------------------
+	Email format check
+--------------------------------------------------------
*/
function isemail(email){
	/*
	var format = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|biz|net|com|gov|mil|org|edu|int)$"
	var matched = new RegExp(format);
	if (email.search(matched) != -1){
		return true;
	}else{
		return false;
	}
	*/
	var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/; 
	flag = pattern.test(email); 
	if(!flag){ 
		return false; 
	} 
	return (true); 
}

/*
+--------------------------------------------------------
+	Phone format check
+--------------------------------------------------------
*/
function isphone(photo){
	return true
}

/*
+--------------------------------------------------------
+	Website style check
+--------------------------------------------------------
*/
function iswebsite(website){
	return true;
}

/*
+--------------------------------------------------------
+	Website style check
+--------------------------------------------------------
*/
function logexprite(url){
	if (typeof jslang.unlogined != 'undefined'){
		alert(jslang.unlogined);
	}
	redirect(url);
}
var showcode = 0;
function valilogin(results,fname,certid,randid){
	if (fname){
		var theform = eval('document.' + fname);
	}else if(document.wane_login){
		fname =  'wane_login';
		var theform = document.wane_login;
	}else{
		var theform = false;
	}
	var code_p; 
	if(randid){code_p = 'certifyimage_login'+randid;}
	else{code_p = 'certifyimage_login';} 
	if (results){
		var altmsg = '';
		var extjav = '';
		switch (results){
			case 'uu' : altmsg = jslang.login_uu;	extjav = 'username'; 		break;
			case 'up' : altmsg = jslang.login_up;	extjav = 'password'; 		break;
			case 'uc' : altmsg = jslang.login_uc;	extjav = 'certifycodeid';certifycode(code_p,fname);	break;
			case 'iu' : altmsg = jslang.login_iu;	extjav = 'username'; 		break;
			case 'ip' : altmsg = jslang.login_ip;	extjav = 'password'; 		break;
			case 'ic' : altmsg = jslang.certified;	extjav = 'certifycodeid';certifycode(code_p,fname);	break;
		}
		if (altmsg != ''){
			alert(altmsg);
		}
		if (extjav && theform){
			eval('theform.' + extjav + '.focus()')
		}
		if (theform && theform.Submit && theform.Submit.disabled){
			theform.Submit.disabled = false;
		}
	}else{
		if (theform && theform.username.value == ''){
			valilogin('uu',fname);
			return false;
		}
		if (theform && theform.password.value == ''){
			valilogin('up',fname);
			return false;
		}
		if (showcode==1 && theform && certid && theform.certifycodeid.value == ''){
			valilogin('uc',fname);
			return false;
		}
		if (theform && theform.Submit){
			theform.Submit.disabled = true;
		}
	}
}
function showCertifycode(fname,randid) {
	var code_p; 
	if(randid){code_p = 'certifyimage_login'+randid;}
	else{code_p = 'certifyimage_login';} 
	if (fname){
		var theform = eval('document.' + fname);
	}else if(document.wane_login){
		fname =  'wane_login';
		var theform = document.wane_login;
	}else{
		var theform = false;
	}
	if(document.getElementById('codeOption').style.display=='none'){
		document.getElementById('codeOption').style.display='';
	}
	if(showcode==0){
		certifycode(code_p,fname);
	}
	showcode = 1;
}
function logouter(url){

	if (typeof jslang.logouter_confirm != 'undefined'){
		if (confirm(jslang.logouter_confirm)){
			var islogoutsubmit = true;
		}else{
			var islogoutsubmit = false;
		}
	}else{
		var islogoutsubmit = true;
	}

	if (islogoutsubmit){
		var logouteid = 'logmsg';
		if ($(logouteid) && typeof jslang.logouter != 'undefined'){
			$(logouteid).innerHTML = jslang.logouter;
		}
		location.href='/index.php/logout.htm';
		/*
		var urls = 'logout';
		if (url){
			urls += '&amp;xml=1';
		}
		Ajax.xml(urls);
		*/
	}

}
